package com.wwj.airline.Controller;

import com.wwj.airline.pojo.Flight;
import com.wwj.airline.pojo.Router;
import com.wwj.airline.Dao.RouterRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/router")
public class RouterHandler {
    @Autowired(required = false)
    private RouterRepository routerRepository;

    @GetMapping("/findAll")
    public List<Router> findAll(){
        return routerRepository.findAll();
    }

    @GetMapping("/findById/{id}")
    public Router findById(@PathVariable("id") Long id){
        return routerRepository.findById(id);
    }

    @PostMapping("/save")
    public void save(@RequestBody Router router){
        routerRepository.save(router);
    }

    @PutMapping("/update")
    public void update(@RequestBody Router router){
        routerRepository.update(router);
    }

    @DeleteMapping("/deleteById/{id}")
    public void deleteById(@PathVariable("id") Long id){
        routerRepository.deleteById(id);
    }
}
